package main

import (
	"flag"
	"fmt"
	"go_19/service/pulsar/pulsar_topic_subscribe"
	"time"
)

func main() {
	fmt.Println("Pulsar Topic Subscribe create")
	var param pulsar_topic_subscribe.TopicSubscribeStruct
	pulsarBroker := flag.String("pulsar_broker", "", "required Pulsar Broker")
	pulsarTopic := flag.String("pulsar_topic", "", "required Topic")
	pulsarSubscribeName := flag.String("pulsar_subscribe_name", "", "需要新增的订阅者名称")
	flag.Parse()

	if *pulsarBroker == "" {
		panic("please input pulsar_broker!")
	}
	if *pulsarTopic == "" {
		panic("please input pulsar_topic!")
	}
	if *pulsarSubscribeName == "" {
		panic("please input pulsar_subscribe_name!")
	}
	param.Topic.ClientOption.URL = *pulsarBroker
	param.Topic.Topic = *pulsarTopic
	param.Topic.SubscriptionName = *pulsarSubscribeName
	param.Topic.ClientOption.ConnectionTimeout = time.Second * time.Duration(5)
	param.Topic.ClientOption.OperationTimeout = time.Second * time.Duration(30)
	param.Topic.ClientOption.MaxConnectionsPerBroker = 1
	param.Topic.SubscriptionType = 0

	pulsar_topic_subscribe.TopicSubscribe(param)
}
